// 第一个参数 回调
// 第二个参数 上下文: context this指向
function myMap(
  this: any,
  callback: (arg0: any, arg1: number) => any,
  context: any
) {
  // eslint-disable-next-line @typescript-eslint/no-this-alias
  const that = this;
  // 返回值
  const res = [];
  for (let i = 0; i < that.length; i++) {
    res.push(callback(that[i], i));
  }
  return res;
}
// @ts-ignore
// eslint-disable-next-line no-extend-native
Array.prototype.myMap = myMap;

// @ts-ignore
const res = [3, 1].myMap((item, index) => {
  // eslint-disable-next-line no-console
  console.log(index);
  return { a: item };
});
// res
